export default {
  namespaced:true,
  state: {
    newBooks: [
      {
        "name": "javasript技术内幕",
        "price": 100,
        "img": "https://img3m7.ddimg.cn/64/26/29120617-1_u_8.jpg"
      },
      {
        "name": "数学之美",
        "price": 44,
        "img": "https://img3m2.ddimg.cn/18/30/28538352-1_b_5.jpg"
      },
      {
        "name": "认知天性",
        "price": 40,
        "img": "https://img3m3.ddimg.cn/74/33/1732997153-3_u_3.jpg"
      }
    ],
    qq:123
  },
  mutations: {
     
  },
  actions: {
     
  },
  getters:{
    sum1(state){
      console.log(state,8877);
      /*reduce(函数【函数的参数：累加值，数组的每一项】，初始值)   ===》返回的是total或者是累加值  */
      return state.newBooks.reduce((total,item)=> total+item.price,0)
    }
  }
}